/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
typedef struct ListNode* SLT;
struct ListNode* reverseList(struct ListNode* head) 
{
	SLT prev = NULL, temp = head, next = NULL;  
	if (head == NULL || head->next == NULL) {  
		return head;  
	}  
	while (temp) {  
		next = temp->next; 
		temp->next = prev; 
		prev = temp; 
		temp = next; 
	}  
	return prev; 
}

